<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property string $name 活动名称
 * @property integer $start_time 开始时间
 * @property integer $end_time 结束时间
 * @property integer $type 活动类型，1全场折扣，2全场满减
 * @property integer $discount 折扣
 * @property integer $full 满多少
 * @property integer $reduce 减多少
 * @property integer $is_enable 是否启用
 */
class GoodsActivity extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_goods_activities';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;


    const DISCOUNT = 1;

    const FULL_REDUCE = 2;

    const TYPE_TEXT = [
        self::DISCOUNT => '折扣',
        self::FULL_REDUCE => '满减'
    ];

    public static function getTypeText($type)
    {
        return self::TYPE_TEXT[$type];
    }

    public static function getStatusText($activity)
    {
        if ($activity['start_time'] >= time()) {
            return '未开始';
        }

        if ($activity['end_time'] <= time()) {
            return '已结束';
        }

        return '进行中';
    }

    public static function isValid($activity)
    {
    }
    
}
